<?php
declare(strict_types=1);

namespace Core\Package\ElementPlus\FormCreate;

use Core\Package\ElementPlus\FormCreate\FormItem\{AudioInput,
    Checkbox,
    Color,
    FileInput,
    FileListInput,
    ImageListInput,
    Map,
    RadioGroup,
    TagsInput,
    MdEditor,
    Password,
    VideoInput,
    VideoListInput,
    DataTime,
    Hidden,
    IcoChoice,
    Input,
    Cascader,
    NumberInput,
    Radio,
    Select,
    SelectMuliple,
    Switchs,
    ImageInput,
    Editor,
    Textarea,
    SearchPanel
};

class FormItem
{
    /**
     * 设置隐藏域
     * @param string $field
     * @param $value
     * @return Hidden
     */
    public static function Hidden(string $field, $value): Hidden
    {
        return new Hidden($field, $value);
    }


    /**
     * 文本输入框
     * @param string $field
     * @param string $title
     * @param string $value
     * @return Input
     */
    public static function Input(string $field, string $title, string $value = ''): Input
    {
        return new Input($field, $title, $value);
    }


    /**
     * 多标签
     * @param string $field
     * @param string $title
     * @param array $value
     * @return TagsInput
     */
    public static function Labels(string $field, string $title, array $value = []): TagsInput
    {
        return new TagsInput($field, $title, $value);
    }


    /**
     * 密码输入框
     * @param string $field
     * @param string $title
     * @param string $value
     * @return Password
     */
    public static function Password(string $field, string $title, string $value = ''): Password
    {
        return new Password($field, $title, $value);
    }


    /**
     * 数字输入器
     * @param string $field
     * @param string $title
     * @param float|int $value
     * @return NumberInput
     */
    public static function Number(string $field, string $title, float|int $value = 0): NumberInput
    {
        return new NumberInput($field, $title, $value);
    }


    /**
     * 单选框
     * @param string $field
     * @param string $title
     * @param float|int|string|bool $value
     * @return Radio
     */
    public static function Radio(string $field, string $title, float|int|string|bool $value = ''): Radio
    {
        return new Radio($field, $title, $value);
    }


    /**
     * 单选框
     * @param string $field
     * @param string $title
     * @param float|int|string|bool $value
     * @return RadioGroup
     */
    public static function RadioGroup(string $field, string $title, float|int|string|bool $value = ''): RadioGroup
    {
        return new RadioGroup($field, $title, $value);
    }


    /**
     * 多选
     * @param string $field
     * @param string $title
     * @param array $value
     * @return Checkbox
     */
    public static function Checkbox(string $field, string $title, array $value = []): Checkbox
    {
        return new Checkbox($field, $title, $value);
    }


    /**
     * 单选框
     * @param string $field
     * @param string $title
     * @param float|int|string|null $value
     * @param bool $non_zero value是否非0
     * @return Select Select
     */
    public static function Select(string $field, string $title, string|int|float|null $value = null, bool $non_zero = false): Select
    {
        if ($non_zero) {
            $value = $value ? $value : '';
        }
        return new Select($field, $title, (string)$value);
    }


    /**
     * 多选框
     * @param string $field
     * @param string $title
     * @param array $value
     * @return SelectMuliple
     */
    public static function SelectMuliple(string $field, string $title, array $value = []): SelectMuliple
    {
        return new SelectMuliple($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string|numeric|bool $value
     * @return Switchs
     */
    public static function Switchs(string $field, string $title, string|bool|int $value = ''): Switchs
    {
        return new Switchs($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return Color
     */
    public static function Color(string $field, string $title, string $value = ''): Color
    {
        return new Color($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return ImageInput
     */
    public static function ImageInput(string $field, string $title, string $value = ''): ImageInput
    {
        return new ImageInput($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param array $value
     * @return ImageListInput
     */
    public static function ImageListInput(string $field, string $title, array $value = []): ImageListInput
    {
        return new ImageListInput($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return VideoInput
     */
    public static function VideoInput(string $field, string $title, string $value = ''): VideoInput
    {
        return new VideoInput($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return AudioInput
     */
    public static function AudioInput(string $field, string $title, string $value = ''): AudioInput
    {
        return new AudioInput($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param array $value
     * @return VideoListInput
     */
    public static function VideoListInput(string $field, string $title, array $value = []): VideoListInput
    {
        return new VideoListInput($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return FileInput
     */
    public static function FileInput(string $field, string $title, string $value = ''): FileInput
    {
        return new FileInput($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param array $value
     * @return FileListInput
     */
    public static function FileListInput(string $field, string $title, array $value = []): FileListInput
    {
        return new FileListInput($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return Editor
     */
    public static function Editor(string $field, string $title, string $value = ''): Editor
    {
        return new Editor($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return MdEditor
     */
    public static function MdEditor(string $field, string $title, string $value = ''): MdEditor
    {
        return new MdEditor($field, $title, $value);
    }


    /**
     * @param string $field
     * @param string $title
     * @param string $value
     * @return Textarea
     */
    public static function Textarea(string $field, string $title, string $value = ''): Textarea
    {
        return new Textarea($field, $title, $value);
    }


    /**
     * 日期时间选择器
     * @param string $field
     * @param string $title
     * @param string $value
     * @return DataTime
     */
    public static function DataTime(string $field, string $title, string $value = ''): DataTime
    {
        return new DataTime($field, $title, $value);
    }


    /**
     * 图标选择器
     * @param string $field
     * @param string $title
     * @param string $value
     * @return IcoChoice
     */
    public static function IcoChoice(string $field, string $title, string $value = ''): IcoChoice
    {
        return new IcoChoice($field, $title, $value);
    }


    /**
     * 级联选择器
     * @param string $field
     * @param string $title
     * @param array $value
     * @return Cascader
     */
    public static function Cascader(string $field, string $title, array $value = []): Cascader
    {
        return new Cascader($field, $title, $value);
    }


    /**
     * 级联选择器
     * @param string $field
     * @param string $title
     * @param array $value
     * @return Map
     */
    public static function Map(string $field, string $title, array $value = ['lng' => '', 'lat' => '']): Map
    {
        return new Map($field, $title, $value);
    }


    /**
     * 搜索面板类型
     * @param string $field
     * @param string $title
     * @param string $api
     * @param array|string|int $value
     * @return SearchPanel
     */
    public static function SearchPanel(string $field, string $title, string $api, array|string|int $value = ''): SearchPanel
    {
        return new SearchPanel($field, $title, $api, $value);
    }
}